<template>
  <div>
    <el-table
      :data="tableData1"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="80">
      </el-table-column>
      <el-table-column
        prop="loanPurpose"
        label="贷款用途"
        width="180">
      </el-table-column>
      <el-table-column
        prop="loanAmount"
        label="贷款金额"
        width="80">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="贷款申请时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="loanDuration"
        label="贷款时长">
      </el-table-column>
      <el-table-column
        prop="status"
        label="贷款申请状态">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="150">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="che(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- Form -->

    <el-dialog title="借款详情" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="贷款用途" :label-width="formLabelWidth">
          <el-input v-model="form.loanPurpose" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="贷款金额" :label-width="formLabelWidth">
          <el-input v-model="form.loanAmount" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="贷款申请时间" :label-width="formLabelWidth">
          <el-input v-model="form.createTime" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="贷款时长" :label-width="formLabelWidth">
          <el-input v-model="form.loanDuration" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="贷款申请状态" :label-width="formLabelWidth">
          <el-input v-model="form.status" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="贷款开始时间" :label-width="formLabelWidth">
          <el-date-picker
            style="width: 100%"
            v-model="form.startTime"
            type="date"
            placeholder="贷款开始时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="checkd('审核未通过')">不通过</el-button>
        <el-button type="primary" @click="checkd('打款中')">通过</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import axios from 'axios'
  axios.defaults.withCredentials=true
  export default {
    name: "registration1",
    data() {
      return {
        tableData1: [],
        dialogFormVisible: false,
        form: {},
        formLabelWidth: '120px'
      }
    },
    methods: {
      findByState(state){
        axios.post("http://localhost:9999/credit-loanapplication/selectByOperatorIdAndStatus",{"operatorId":null,"status":state}).then(res=>{
            this.tableData1=res.data;

        })
      },
      checkd(mes){
        this.dialogFormVisible=false;
        this.form.status=mes;
        axios.post("http://localhost:9999/credit-loanapplication/updateOne",this.form).then(res=>{
          if(res.data.code!=200){
            alert(res.data.message)
          }if(res.data.code==200){
            alert(res.data.message)
            this.findByState("审核中");
          }
        })

      },
      che(row){
        this.dialogFormVisible=true;
        this.form=row;
      }
    },
    mounted(){
      this.findByState("审核中")
    }
  }
</script>

<style scoped>

</style>
